package com.components;

import com.argsstack.Args;
import com.exceptions.PreIsNotSatisfiedException;
import com.post.BasicPost;
import com.post.Terminator;
import com.pre.BasicPre;

public abstract class BaseComponent {

    private final String goalName;

    public BaseComponent(String goal) {
        this.goalName = goal;
    }

    protected void checkPrerequisites(Args args, Object... prereqs) {
        for (Object p : prereqs) {
            if (!args.contains(p)) {
                throw new PreIsNotSatisfiedException();
            }
        }
    }

    public BasicPre pre(Args args) {
        return BasicPre.FalsePre;
    }

    public BasicPost post(Args args) {
        return new Terminator();
    }

    public abstract void execute(Args args);
}
